home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (DO) / Nibble Volume 09, No. 07 (1988-07)(MicroSPARC)(Side B).zip / Nibble Volume 09, No. 07 (1988-07)(MicroSPARC)(Side B).do / SWAT.JOYSTICK.S < prev    next >
Text File  |  1996-12-24  |  6KB  |  6 lines

  1.                         ;2**************************************************2*                                                *2*                 SWAT.JOYSTICK                  *2*                                                *2*             by S. Scott Zimmerman              *2*              Copyright (c) 1988                *2*              by MicroSPARC, Inc                *2*              Concord, MA  01742                *2*                                                *2*           The MicroSPARC Assembler             *2*                                                *2**************************************************  ORG $8000 ;Decimal 32768 2**************************************************2*  EQUates:                                      *2************************************************** FLINDX EQU $00 ;Fly index$XSWAT EQU $02 ;X position of swatter$YSWAT EQU $03 ;Y position of swatter XINPUT EQU $04 ;X position input YINPUT EQU $05 ;Y position input"NFLIES EQU $06 ;Current # of flies DELAY EQU $C0 ;Delay constant 2**************************************************2*  Low-Resolution Graphics Routines:             *2************************************************** #PLOT EQU $F800 ;Plot a lo-res point"SETCOL EQU $F864 ;Set lo-res color#SCRN EQU $F871 ;Get color on screen%SETGR EQU $FB40 ;Set low-res graphics 2**************************************************2*  Joystick (paddle) Addresses/Routines:         *2************************************************** $BUTTON0 EQU $C061 ;Button 0 locatoin$BUTTON1 EQU $C062 ;Button 1 location$PREAD EQU $FB1E ;Read X paddle, in Y 2**************************************************2*  Other Monitor Routines:                       *2************************************************** (SPEAKER EQU $C030 ;Apple speaker address#SNGFLT EQU $E301 ;Float single byte(CONINT EQU $E6FB ;Convert FAC to integer!FMULTT EQU $E982 ;Mult FAC by ARG$CONUPK EQU $E9E3 ;Move memory to ARGMUL10 EQU $EA39 ;Mult FAC by 10&RND EQU $EFAE ;Random number generatorSETTXT EQU $FB39 ;Set text mode!HOME EQU $FC58 ;Clear text screen$WAIT EQU $FCA8 ;Monitor wait (delay) 2**************************************************2*  Program MAIN and MAINLOOP                     *2************************************************** ! JSR SETUP ;Prepare to start game JSR GOODTONE ;Sound tone 'MAINLOOP JSR GETXY ;Get X,Y coordinates JSR MOVESWAT ;Move swatter JSR CHECKHIT ;Check if hit fly JSR MOVFLIES ;Move flies LDA #DELAY ;Pause here...  JSR WAIT ;...using monitor wait LDA NFLIES ;All flies gone? BPL MAINLOOP ;No, go again JSR GOODTONE ;Yes, sound tone JSR SETTXT ;Set text mode JSR HOME ;Clear screen JMP $3D0 ;Warmstart Applesoft 2**************************************************2*  SUBROUTINES:                                  *2************************************************** %SETUP JSR SETGR ;Init lo-res graphics JSR HOME ;Clear text window JSR SETFLIES ;Draw init flies  JSR INITVALS ;Initialize values JSR GETXY ;Get initial X,Y  JSR COPYXY ;Copy input to value JSR PUTSWAT ;Put swat there RTS ;End of SETUP $SETFLIES LDA #12 ;Set color to green  JSR SETCOL LDX #9 ;Set for 10 flies#SFLOOP STX FLINDX ;Save index value$AGAIN JSR RNDINT ;Get randon integer LDX FLINDX ;Restore X index  STA XFLY,X ;Save X value of fly JSR RNDINT ;Get random integer LDX FLINDX ;Restore X index  STA YFLY,X ;Save Y value of fly LDY XFLY,X ;Set A,Y for SCRN JSR SCRN ;Get color there TAY ;Is it zero? BNE AGAIN ;No, so go again LDA YFLY,X ;Get coords back  LDY XFLY,X JSR PLOT ;Plot point LDX FLINDX ;Get index DEX ;Go to next fly  BPL SFLOOP ;Go agin if not done RTS ;End of SETFLIES %INITVALS LDX #9 ;Set num - 1 of flies STX NFLIES ; to ten LDA #1 ;Initialize fly flags'IVLOOP STA FLFLAG,X ;Zero the fly flags DEX ;End of loop? BPL IVLOOP ;No, go again RTS HITTONE LDA #80 ;Get pitch LDX #10 ;Get duration BNE TONE ;Aways branchGOODTONE LDA #30 ;Get pitch LDX #80 ;Get durationTONE TAY ;Save pitch'TONELOOP BIT SPEAKER ;Click the speaker TYA ;Get pitch (delay) JSR WAIT ;Pause here DEX ;Decrement duration% BNE TONELOOP ;Loop if pitch not done RTS GETXY LDX #0 ;Set to paddle 0 JSR PREAD ;Get current reading! JSR SNGFLT ;Float value into FAC$ LDA #FSCALE ;Multiplier for scaling
  2.           LDY #FSCALE/ JSR CONUPK ;Move to ARG JSR FMULTT ;Mult X by scale JSR CONINT ;Take integral part STX XINPUT ;Save as X input LDA #$20 ;Pause to avoid JSR WAIT ; XY inteference LDX #1 ;Set to paddle 1 JSR PREAD ;Get current reading! JSR SNGFLT ;Float value into FAC$ LDA #FSCALE ;Divisor to scale value
  3.           LDY #FSCALE/ JSR CONUPK ;Move to ARG JSR FMULTT ;Mult Y by scale JSR CONINT ;Take integral part STX YINPUT ;Save as Y input RTS $COPYXY LDA XINPUT ;Get current input STA XSWAT ;Save as swat X LDA YINPUT ;Get current input STA YSWAT ;Save as swat Y RTS #PUTSWAT LDA #15 ;Set color to white  JSR SETCOL ;Go set lo-res color LDA YSWAT ;Get coordinates
  4.  LDY XSWAT JMP PLOT ;Plot swat on screen #MOVESWAT LDA #0 ;Set color to black JSR SETCOL ; for erasing BIT BUTTON0 ;Don't move if a BMI MSEXIT ; button is down  BIT BUTTON1  BMI MSEXIT LDA YSWAT ;Get coordinates CMP YINPUT ;Is it different? BNE ERASEIT ;Yes, go erase it
  5.  LDY XSWAT CPY XINPUT ;Is it different BNE ERASEIT ;Yes, erase itMSEXIT RTS ;No need to move it'ERASEIT LDY XSWAT ;Make sure X in Y-reg JSR PLOT ;Erase swat JSR COPYXY ;Put new in current JMP PUTSWAT ;Go plot new %CHECKHIT LDX #9 ;Check flies for hits$CHLOOP LDA FLFLAG,X ;Is this fly on?! BEQ CHEND ;No, go to end of loop LDA XFLY,X ;Get fly X value CMP XSWAT ;Location of swat?! BNE CHEND ;No, go to end of loop LDA YFLY,X ;Get fly Y value CMP YSWAT ;Location of swat?! BNE CHEND ;No, go to end of loop BIT BUTTON0 ;Is button on? BMI HIT ;Yes, it's a hit BIT BUTTON1 ;Is this one on? BMI HIT ;Yes, it's a hit RTS ;No, so just quitHIT LDA #0 ;Zero this flag
  6.